package com.ruoyi.system.api.factory;

import com.ruoyi.common.core.domain.R;
import com.ruoyi.common.core.web.domain.AjaxResult;
import com.ruoyi.system.api.RemoteManagerService;
import com.ruoyi.system.api.domain.Content;
import org.slf4j.Logger;
import org.slf4j.LoggerFactory;
import org.springframework.cloud.openfeign.FallbackFactory;
import org.springframework.stereotype.Component;

import java.util.List;

/**
 * 作者：Dzm
 * 时间：2024-09-09-9:47
 * 功能：
 */

@Component
public class RemoteManagerFallbackFactory implements FallbackFactory<RemoteManagerService> {

    private static final Logger log = LoggerFactory.getLogger(RemoteFileFallbackFactory.class);
    @Override
    public RemoteManagerService create(Throwable throwable) {
        log.error("调用商品管理模块异常");

        return new RemoteManagerService() {

            @Override
            public R<List<Content>> getContentsByCateId(Long id) {
                return R.fail("通过广告分类id获取广告失败:" + throwable.getMessage());
            }

            @Override
            public R<Content> getContentById(Long id) {
                return R.fail("通过广告id获取广告失败:" + throwable.getMessage());
            }
        };
    }
}
